<template>
	<view class="box">
		<view class="first">
			<view class="firstBox">
				<view class="firstView">
					<image src="../../static/seach.png" class="firstImg" />
					<input v-model="paginatin.keyword" placeholder="输入关键词搜索试试" @keydown.enter="getList(true)" />
				</view>
				<view class="firstView">
					<view class="firsttext"></view>
					<view class="firsttext2" @click="getList(true)">搜索</view>
				</view>
			</view>
		</view>
		<view class="second">
			<view class="headline_content">
				<view class="card" v-for="(item,index) in list" :key="index"
					@click="onNav(`/pages/headlineDetails/index?id=${item.cyrappNewsId}`)">
					<view class="items">
						<image class="left_img" :src="item.headImg"> </image>
						<view class="right_box">
							<view class="text">{{item.title}}</view>
							<view class="read_count">
								<view>{{item.author}}</view>
								<view>阅 3849</view>
							</view>
						</view>
					</view> 
				</view>
			</view>
			<view class="third">别滑啦，我也是有底线的啦～</view>
		</view>
	</view>
</template>

<script>
	import {
		getArticle
	} from '../../api/article';
	export default {
		data() {
			return {
				paginatin: {
					pageNum: 1,
					pageSize: 15,
					keyword: '',
				},
				list: [],
				total: 0,
			}
		},
		mounted() {
			this.getList(true);
			// #ifdef APP-PLUS
			uni.setNavigationBarColor({
				frontColor:"#fff",
				
				backgroundColor:"#fff",
			})
			// #endif  
		},
		onReachBottom() {
			this.getList(false);
		},
		methods: {
			async getList(init) {
				if (init) {
					this.list = [];
					this.paginatin.pageNum = 1;
				}
				if (init || this.total > this.list.length) {
					const {
						data
					} = await getArticle(this.paginatin);
					this.list = this.list.concat(data.records);
					this.total = data.total;
					this.paginatin.pageNum++;
				}
			},
			onNav(url) {
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>
<style>
	page {
		background-color: #F5F7FA;
	}
</style>
<style lang="less" scoped>
	@import './index.less';
</style>